<template>
	<view>
		<view class="body-view">
			<u-navbar :background="background" back-icon-color="#FFFFFF">
			</u-navbar>
			<view class="reportView">
				<view class="health pattern-inBa">
					<view class="weui-flex">
						<view>
							<view class="placeholder">
								<view class="rateStyle" v-if="!result.healthLevel">
									<view class="scoreText noScore">
									</view>
								</view>
								<view class="rateStyle" v-else>
									<view class="scoreText">
										{{result.healthLevel}}
									</view>
									<view class="rateViews">
										<uni-rate :size="11" :value="result.starNum" :readonly="true" />
									</view>
								</view>
							</view>
						</view>
						<view class="weui-flex" style="width: 400upx;">
							<view class="placeholder">
								<view class="levelStyle">
									<view class="healthTitle">
										{{nameShare}}的体质：{{result.kindName}}质
									</view>
									您的水平超过了100%的人
								</view>
							</view>
						</view>
						<view class="weui-flex">
							<view class="placeholder">
								<button class="tworen" open-type='share'>
								</button>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="constitution">
				<view class="constitution-flex">
					<view class="constitution-item" v-for="(item,index) in result.medicalScoreList">
						<view class="constitution-height">
							<view class="constitution-Aheight" :class="item.kindName==result.kindName?'actavebg':''"
								:style="'height:'+item.kindScore*2+'rpx'">
							</view>
						</view>
						<view class="constitution-text" :style="item.kindName==result.kindName?'color:#B01C2E':''">
							<!-- 平和 -->
							{{item.kindName}}
						</view>
					</view>
				</view>
				<view class="constitution-describe">
					<!-- 阻遏气机，常致血瘀，形成痰瘀互夹，治宣活血养血，兼以化痰。 -->
					{{result.cmcExplain}}
				</view>
				<view class="constitution-result" @click="isExplain=!isExplain">
					<image src="http://static.bsyjk.cn/warning/FDFD6A739DDF4670A2527FE0BF821314.png" mode=""></image>
					体质结果说明 <text>点击阅读</text>
				</view>
				<view v-show="isExplain" style="color: rgba(0, 0, 0, 0.26);padding-top: 10rpx;">
					<text>
						1、本测试来自《中国体质分类与判定》，这是中华中医药学会于2009年4月9日颁布的国家标准。
						2、上方图表显示了你的体质详情，超过红线是主体质和兼和体质，超过棕色线是倾向体质。
						3、多种体质并存是多数人的状态。不必过于担心，调整生活方式是有改变的可能的。根据你独特的情况，我们推荐你首先改善当前体质，其他体质也会逐渐改善。
					</text>
				</view>
			</view>
			<!-- 体质 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						{{result.kindName}}质体质可能会
					</view>
				</view>
				<view class="incident">
					<view class="incident-item" v-for="(item,index) in result.symptomNames" :key="index">
						{{item}}
					</view>
				</view>
			</view>
			<!-- 意思 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						{{result.kindName}}，究竟是什么意思？
					</view>
					<view class="BodyMass-rview">

					</view>
				</view>
				<view class="incident" style="margin-left: 0;">
					<view class="Meaning-class">
						<view class="Meaning-viewfl">
						</view>
						{{result.meaning}}
						<!-- 眼睛常有红丝，常常出现疼痛，容易烦躁、健忘、性情急躁。眼睛常有红丝，常常出现疼痛，容易烦躁。 -->
					</view>
				</view>
			</view>
			<!-- 困扰 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						{{result.kindName}}体质的困扰
					</view>
					<view class="BodyMass-rview">

					</view>
				</view>
				<view class="incident" style="margin-left: 0;">
					<view class="Meaning-class">
						<view class="Meaning-viewfl">
						</view>
						{{result.worry}}
						<!-- 眼睛常有红丝，常常出现疼痛，容易烦躁、健忘、性情急躁。眼睛常有红丝，常常出现疼痛，容易烦躁。 -->
					</view>
				</view>
			</view>
			<!-- 警惕 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						这些是{{result.kindName}}质最需要警惕的
					</view>
					<view class="BodyMass-rview">

					</view>
				</view>
				<view class="incident" style="margin-left: 0;">
					<view class="Meaning-class">
						<view class="Meaning-viewfl">
						</view>
						{{result.beVigilant}}
						<!-- 眼睛常有红丝，常常出现疼痛，容易烦躁、健忘、性情急躁。眼睛常有红丝，常常出现疼痛，容易烦躁。 -->
					</view>
				</view>
			</view>
			<!-- 为什么 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						我为什么会{{result.kindName}}？
					</view>
					<view class="BodyMass-rview">

					</view>
				</view>
				<view class="incident" style="margin-left: 0;">
					<view class="Meaning-class">
						<view class="Meaning-viewfl">
						</view>
						{{result.reason}}
						<!-- 眼睛常有红丝，常常出现疼痛，容易烦躁、健忘、性情急躁。眼睛常有红丝，常常出现疼痛，容易烦躁。 -->
					</view>
				</view>
			</view>
			<!-- 日常建议 -->
			<view class="Body-mass">
				<view class="BodyMass-Title">
					<view class="BodyMass-leftV">
					</view>
					<view class="BodyMass-text">
						日常建议
					</view>
					<view class="BodyMass-rview">

					</view>
				</view>
				<view class="incident" style="margin-left: 0;">
					<view class="Meaning-class">
						<view class="Meaning-viewfl">
						</view>
						{{result.suggest}}
						<!-- 眼睛常有红丝，常常出现疼痛，容易烦躁、健忘、性情急躁。眼睛常有红丝，常常出现疼痛，容易烦躁。 -->
					</view>
				</view>
			</view>
			<!-- 2+1 -->
			<view class="TCMReportBG"  v-if="nameShare == '您'">
				<view class="TCMReportBG-titleView">
					<view class="TCMReportBG-text">
						{{resultX.healthLevel?'2+1测评您的健康综合水平：'+resultX.healthLevel+'等级':'2+1测评您的健康综合水平：无'}}
					</view>
					<view class="TCMReportBG-btn" @tap="fengxbaog(result.starNum)">
						{{resultX.healthLevel?'点击查看':'去评估'}}
					</view>
				</view>
				<view class="TCMReportBG-center">
					{{resultX.healthLevel?'总体特征：您的综合健康状态较差，建议您及时就医，注意生活习惯，平衡膳食，合理运':'您还没有去评估健康风险报告'}}
				</view>
			</view>
			<!-- 高度 -->
			<view style="height: 200rpx;"></view>
			<!-- 评测 -->
			<view class="pingcegs"  v-if="nameShare == '您'">
				<button class="pingcegs-cp"
					@tap="navurl('/pages/subpackage/home/oneAccess/evaluating?pageMy='+pageMy,false)"
					type="default">重新测评</button>
				<button class="pingcegs-tl"
					@tap="navurl('/subpackage/Conditioning/Conditioning?userAnsId='+userAnsId+'&constitutionId='+result.constitutionId,false)"
					type="default">调理改善</button>
			</view>
		</view>
	</view>
</template>

<script>

import uNavbar from "@/uview-ui/components/u-navbar/u-navbar.vue"

	export default {
		components: {
			uNavbar
		},
		data() {
			return {
				resultX: {}, //2+1报告
				isExplain: false, //展示说明
				nameShare: '您',
				userAnsId: '', //报告id
				result: {}, //中医报告数据
				evaluating: true,
				background: {
					backgroundColor: '#BB9D7A'
				},
			}
		},
		onLoad(e) {
			console.log(e, '139999999999999')
			// e.nickName = '广远'
			if (e.nickName) {
				this.nameShare = e.nickName
			}
			if (e.userAnsId) { //中医报告
				this.userAnsId = e.userAnsId
				this.chineseMedical(e.phone, e.userAnsId)
			}else{
				this.zYgetLast(uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').phone, '4')
			}
			this.userAnswer() //2+1报告
			// 分享
			wx.showShareMenu({
				withShareTicket: true,
				//设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
				menus: ["shareAppMessage", "shareTimeline"]
			})
		},
		methods: {
			fengxbaog(starNum) {
					if (starNum) {
						uni.navigateTo({
							url: '/pages/subpackage/home/HealthReport/HealthReport?userAnsId=' + uni
								.getStorageSync(
									'userAnsId')
						})
					} else {
						uni.navigateTo({
							url: '/pages/subpackage/home/oneAccess/evaluating'
						})
					}
			},
			// 获取2+1报告
			userAnswer() {
				let _this = this;
				//  uni.getStorageSync('userAnsId') ? uni.getStorageSync('userAnsId') : '0'
				let topicId = 3,
					starNum; //星
				this.$api.get(global.apiUrls.userAnswer + '/' + uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId + '/' + topicId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let result = res.data.result;
							_this.resultX = result; //健康报告
						}
					}).catch(err => {})
			},
			//发送给朋友
			onShareAppMessage(res) {
				// 此处的distSource为分享者的部分信息，需要传递给其他人
				let USER_DATA_BSY_Z = uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z')
				return {
					title: this.shareTitle,
					type: 0,
					path: '/pages/tab/home?userAnsId=' + this.userAnsId + '&type=7&nickName=' + USER_DATA_BSY_Z.nickName +
						'&avatarUrl=' + USER_DATA_BSY_Z.avatarUrl+'&phone='+uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').phone,
					summary: "",
					// imageUrl: "https://58d.oss-cn-hangzhou.aliyuncs.com/goods/ttg_1596073788000.png"
				}
			},
			navurl(url, data) {
				console.log(url, data, 4500000)
				// return
				if (data == false) {
					this.$urouter.navigateTo({
						url: url,
						params: {}
					});
				} else {
					this.$urouter.navigateTo({
						url: url,
						params: {
							goodFoods: JSON.stringify(data.goodFoods),
							goodSport: JSON.stringify(data.goodSport),
							improvePlanInfo: JSON.stringify(data.improvePlanInfo),
							goodVideos: JSON.stringify(data.goodVideos)
						}
					});
				}
			},
			// 获取最近一次中医报告
			zYgetLast(phone, topicId) { //首页添加健康豆
				let _this = this;
				this.$api.get(global.apiUrls.zYgetLast + '/' + phone + '/' + topicId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let result = res.data.result;
							// 星判断
							let starNum;
							if (result.healthLevel == 'A') {
								starNum = 5
							} else if (result.healthLevel == "B") {
								starNum = 4
							} else if (result.healthLevel == "C") {
								starNum = 3
							} else if (result.healthLevel == "D") {
								starNum = 2
							} else if (result.healthLevel == "E") {
								starNum = 1
							}
							result.starNum = starNum
							_this.result = result
						}
					}).catch(err => {})
			},

			chineseMedical(phone, userAnsId) { //首页添加健康豆
				let _this = this;
				this.$api.get(global.apiUrls.chineseMedical + '/' + phone + '/' + userAnsId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let result = res.data.result;
							// 星判断
							let starNum;
							if (result.healthLevel == 'A') {
								starNum = 5
							} else if (result.healthLevel == "B") {
								starNum = 4
							} else if (result.healthLevel == "C") {
								starNum = 3
							} else if (result.healthLevel == "D") {
								starNum = 2
							} else if (result.healthLevel == "E") {
								starNum = 1
							}
							result.starNum = starNum
							_this.result = result
						}
					}).catch(err => {})
			},
		}
	}
</script>

<style lang="scss">
	.body-view {
		width: 750upx;
		min-height: 2300upx;
		background: url(http://static.bsyjk.cn/body-viewBG/E97DE1FF6A1544D88297ADD32E345FFD.jpeg);
		background-size: 100% 100%;
		padding-top: 1upx;

		// 评测分数
		.reportView {
			width: 708upx;
			height: 170upx;
			border-radius: 40upx 40upx 0 0;
			margin: 30upx auto 0;
			bottom: 2upx;

			.reportTitle {
				view {
					text {
						font-size: 36upx;
						font-weight: 800;
						color: #4A4A4A;
						position: relative;
					}

					text::before {
						content: '';
						position: absolute;
						top: 10upx;
						right: -30rpx;
						border-top: 15upx solid transparent;
						border-left: 20upx solid #2EA7E0;
						border-bottom: 15upx solid transparent;
					}

					padding: 0 12upx 0 15upx;
					font-size: 24upx;
					font-family: PingFang-SC-Heavy,
					PingFang-SC;
					line-height: 50upx;
					color: #9B9B9B;
				}
			}
		}

		.health {
			width: 708upx;
			height: 175upx;
			background: url(http://static.bsyjk.cn/topbg/D41800DF6F434DE7B1D1FFCB21CF3EF3.png) no-repeat;
			background-size: 708upx 175upx;
			margin-bottom: 30upx;

			.rateViews {
				padding-left: 10upx;
				transform: scale(0.7);
			}

			.rateStyle {
				width: 144upx;
				height: 144upx;
				margin: 19upx 23upx 0 18upx;
				background: url(http://static.bsyjk.cn/Group2x/EB5AB2CBF6F44A9B8C153366402D2CAA.png) no-repeat;
				background-size: 144upx 144upx;
			}

			.levelStyle {
				margin: 50upx 0 0;
				color: #81C042;
				font-size: 24upx;

				.healthTitle {
					font-weight: 500;
					font-size: 36upx;
					line-height: 50upx;
				}
			}

			.tworen {
				width: 47upx;
				height: 40upx;
				margin: 50upx 0 0 50upx;
				background: url(http://static.bsyjk.cn/tworen/1552D344E1974B55B6886E447A4B1014.png)no-repeat;
				background-size: 100% 100%;
			}

			.scoreText {
				width: 50upx;
				font-size: 60upx;
				font-family: Swiss721BT-Black, Swiss721BT;
				font-weight: 900;
				color: #F5A623;
				line-height: 72upx;
				letter-spacing: 3upx;
				margin: 0 auto;
				padding-top: 19upx;
			}
		}

		.pattern-inBa {
			background: url(http://static.bsyjk.cn/patternBg/7A6CDFC08890455D916AC52E5B677828.png) no-repeat;
			background-size: 708rpx 175rpx;

			.rateStyle {
				background: url(http://static.bsyjk.cn/Groupx/AA8876910E2C4B1CA04453DD63231DD0.png)no-repeat;
				background-size: 100% 100%;
			}

			.levelStyle {
				color: #9B7C57;
			}
		}

		.noScore {
			position: relative;
		}

		.noScore::before {
			content: '';
			width: 33upx;
			height: 6upx;
			position: absolute;
			top: 70upx;
			left: -18upx;
			border-radius: 20upx;
			background: #F5A623;
		}

		.noScore::after {
			content: '';
			width: 33upx;
			height: 6upx;
			position: absolute;
			top: 70upx;
			left: 36upx;
			border-radius: 20upx;
			background: #F5A623;
		}

		.constitution {
			width: 708upx;
			padding: 30upx;
			background: #fff;
			margin: 0 auto;
			border-radius: 0 0 25upx 25upx;

			.constitution-flex {
				display: flex;

				.constitution-item {
					width: 100upx;

					.constitution-height {
						height: 170upx;
						position: relative;
						width: 25upx;
						margin: 0 auto 0;

						.constitution-Aheight {
							width: 25upx;
							position: absolute;
							background: #9B7C57;
							bottom: 0;
						}

						.actavebg {
							background: #B01C2E;
						}
					}

					.constitution-text {
						font-size: 24upx;
						color: rgba(0, 0, 0, 0.26);
						text-align: center;
						padding-top: 8upx;
					}
				}
			}

			.constitution-describe {
				width: 637upx;
				margin: 0 auto;
				color: #333333;
				line-height: 53upx;
			}

			.constitution-result {
				padding-top: 30rpx;
				color: rgba(0, 0, 0, 0.26);

				image {
					width: 36upx;
					height: 36upx;
					display: block;
					float: left;
					margin: 0 14upx 0 0;
				}


				text {
					padding-left: 10upx;
					text-decoration: underline;
				}
			}
		}

		.Body-mass {
			width: 706upx;
			padding: 30upx;
			background: #fff;
			margin: 30upx auto 0;
			border-radius: 25upx;

			.BodyMass-Title {
				display: flex;
				font-size: 36upx;
				font-weight: 500;
				height: 74upx;

				.BodyMass-leftV {
					width: 10upx;
					height: 26upx;
					background: #9B7C57;
					border-radius: 5upx;
					margin: 12upx 10upx 0 0;
				}

				border-bottom: 1px solid #D8D8D8;
			}

			.incident {
				display: flex;
				justify-content: left;
				flex-wrap: wrap;
				margin-left: -30upx;

				.incident-item {
					width: 140upx;
					height: 44upx;
					line-height: 44upx;
					text-align: center;
					color: #fff;
					background: #9B7C57;
					border-radius: 8upx;
					margin: 20upx 0 0 30upx;
				}

				.Meaning-class {
					width: 100%;
					padding: 28upx 0 0;
					color: #9B9B9B;

					.Meaning-viewfl {
						width: 15upx;
						height: 15upx;
						border-radius: 50%;
						background: #9B7C57;
						float: left;
						margin: 10upx 10upx 0;
					}
				}
			}
		}

		.TCMReportBG {
			width: 708upx;
			height: 175upx;
			margin: 30upx auto 0;
			background: url(http://static.bsyjk.cn/marshalling/2D877BE6CB06461A920AA2972C17CDD8.png)no-repeat;
			background-size: 708upx 175upx;

			.TCMReportBG-titleView {
				display: flex;
				padding: 22upx 20upx 6upx 30upx;
				color: #9B7C57;

				.TCMReportBG-text {
					width: 560upx;
					font-size: 30upx;
				}

				.TCMReportBG-btn {
					width: 125upx;
					height: 40upx;
					line-height: 40upx;
					text-align: center;
					color: #fff;
					background: #9B7C57;
					border-radius: 42upx;
					font-size: 24upx;
				}
			}

			.TCMReportBG-center {
				padding: 0 30upx;
				font-size: 26upx;
				color: #9B7C57;
			}
		}

		.pingcegs {
			width: 750upx;
			height: 197upx;
			position: fixed;
			background: url(http://static.bsyjk.cn/body-viewBG/E97DE1FF6A1544D88297ADD32E345FFD.jpeg) 0 300upx;
			background-size: 750upx 3161upx;
			bottom: 0;
			display: flex;

			.pingcegs-cp,
			.pingcegs-tl {
				width: 326upx;
				height: 80upx;
				border-radius: 40upx;
				font-size: 24upx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				line-height: 80upx;
				background: none;
				color: #fff;
				margin: 33upx;
				border: 1px solid #fff;
			}

			.pingcegs-tl {
				background: #9B7C57;
				color: #fff;
				border: none;
			}
		}
	}
</style>
